package com.rabbit.eap.framework.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.web.client.RestTemplate;

/**
 * @projectName eap
 * @packageName com.rabbit.eap.config
 * @className RestTemplateConfig
 * @author： rabbit
 * @version： 1.0
 * @since： 2020/4/27 21:40
 * <p>Description: RestTemplateConfig </p>

 */
@Configuration
public class RestTemplateConfig {
    public static final int readTimeout = 50000;
    @Bean
    public RestTemplate restTemplate(ClientHttpRequestFactory factory){
        return new RestTemplate(factory);
    }

    @Bean
    public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
        SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
        //单位为ms
        factory.setReadTimeout(readTimeout);
        //单位为ms
        factory.setConnectTimeout(readTimeout);
        return factory;
    }
}
